close all;clear;clc
% 余弦退火学习率
minLr = 0.0001;
maxLr = 0.01;
x = 1:10000;
y = zeros(size(x));
dy = y;
for i = x
    y(i) = minLr + 0.5 *(maxLr - minLr)*(1+cos(i/max(x)*pi));
    dy(i) =- 0.5 *(maxLr - minLr)*sin(i/max(x)*pi)*pi/max(x);
end
figure('position',[100 100 640*2 480]);
axis off
subplot(1,2,1);hold on;
ax = gca;
ax.Position=[0.05 0.1 0.4 0.85];
plot(x,y,'r-');
xlabel('epoch')
ylabel('learning rate')
subplot(1,2,2);hold on;
ax = gca;
ax.Position=[0.55 0.1 0.4 0.85];
plot(x,dy,'b-.');
xlabel('epoch')
ylabel('lr gradient')

